
import 'dart:async';
import '../utils/ApiService.dart';
import 'definitions/ResultTodoListModel.dart';
import 'definitions/ResultModel.dart';
import 'definitions/CreateTodoModelParams.dart';
import 'definitions/IdsParams.dart';
import 'definitions/IdParams.dart';
import 'definitions/ResultTodoModel.dart';
import 'definitions/ResultTodoList.dart';


class TodoController {

    static String listUsingGetPath = "/api/todo/list";
    /// 1. 所有用户关联分组的待办事项
    static Future<ResultTodoListModel> listUsingGet(num page, num page_size, [dynamic headers]) async {
      var response = await ApiService.get("/api/todo/list?page=${page ?? "" }&page_size=${page_size ?? "" }", {}, headers);
      return ResultTodoListModel()..fromJson(response.data);
    }
    
    static String createUsingPostPath = "/api/todo/create";
    /// 2. 添加代办事项
    static Future<ResultModel> createUsingPost(CreateTodoModelParams data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/todo/create", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String collectUsingPostPath = "/api/todo/collect";
    /// 3. 收藏代办事项
    static Future<ResultModel> collectUsingPost(IdsParams data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/todo/collect", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String cancelCollectUsingPostPath = "/api/todo/cancelCollect";
    /// 4. 取消收藏代办事项
    static Future<ResultModel> cancelCollectUsingPost(IdsParams data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/todo/cancelCollect", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String removeUsingPostPath = "/api/todo/remove";
    /// 5. 终止代办事项
    static Future<ResultModel> removeUsingPost(IdParams data,[ dynamic headers ]) async {
      var response = await ApiService.post("/api/todo/remove", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String updateUsingPutPath = "/api/todo/update/{id}";
    /// 6. 更改代办事项
    static Future<ResultModel> updateUsingPut(String id, CreateTodoModelParams data,[ dynamic headers ]) async {
      var response = await ApiService.put("/api/todo/update/$id", data.toJson() , headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String historyListUsingGetPath = "/api/todo/list/history";
    /// 7. 历史代办事项
    static Future<ResultModel> historyListUsingGet(num page, num page_size, [dynamic headers]) async {
      var response = await ApiService.get("/api/todo/list/history?page=${page ?? "" }&page_size=${page_size ?? "" }", {}, headers);
      return ResultModel()..fromJson(response.data);
    }
    
    static String collectListUsingGetPath = "/api/todo/list/collect";
    /// 8. 我收藏的待办事项
    static Future<ResultTodoListModel> collectListUsingGet(num page, num page_size, [dynamic headers]) async {
      var response = await ApiService.get("/api/todo/list/collect?page=${page ?? "" }&page_size=${page_size ?? "" }", {}, headers);
      return ResultTodoListModel()..fromJson(response.data);
    }
    
    static String detailUsingGetPath = "/api/todo/detail/{id}";
    /// 9. 待办事项详情
    static Future<ResultTodoModel> detailUsingGet(String id, [dynamic headers]) async {
      var response = await ApiService.get("/api/todo/detail/$id", {}, headers);
      return ResultTodoModel()..fromJson(response.data);
    }
    
    static String listByGroupIdUsingGetPath = "/api/todo/listByGroupId/{id}";
    /// 10. 根据分组id获取待办事项列表
    static Future<ResultTodoList> listByGroupIdUsingGet(String id, [dynamic headers]) async {
      var response = await ApiService.get("/api/todo/listByGroupId/$id", {}, headers);
      return ResultTodoList()..fromJson(response.data);
    }
    
}